<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/12/20
 * Time: 22:01
 */

namespace Xcx\Model;


class UsersModel extends BaseModel {

    public function __construct()
    {
        parent::__construct();
    }

    /**
     * 获取用户信息
     * @return array|false|mixed|\PDOStatement|string|\think\Model
     */
    public function getUserInfo()
    {
        $user = M('users')->where(array('id'=>$this->uid))->find();
        if (is_array($user) && count($user) > 0) {
            $header = getUploadImgDir($user['header'],'user_head');
            $user['header'] = $header;
            return $user;
        }
        return array();
    }

    /**
     * 增加用户被赞数量
     * @param $uid
     * @param $count
     * @return bool
     */
    public function setIncAllPraiseCount($uid,$count = 1)
    {
        $maps['id'] = $uid;
        return $this->where($maps)->setInc('all_praise',$count);
    }

    /**
     * 添加用户积分消费总量
     * @param $count
     * @return bool|int|true
     */
    public function setIncUsePraiseCount($count)
    {
        $maps['id'] = $this->uid;
        return $this->where($maps)->setInc('use_praise',$count);
    }
}